#include"../include/p.h"
int myinsert(int newfd,sqlite3 *mydb,char *tbname,char *buf)
{
	//1解析字符串 把 传过来的字符串分解成三个字符串 
	//1.modid 2 modname 3 property/
	//调用解析字符串
	char id[50]={0};
	char modname[50]={0};
	char property[50]={0};

	parsestr1(buf,id,modname,property);
	printf("%s\n",id);
	printf("%s\n",modname);
	printf("%s\n",property);
	//插入结构体；
	Mymod newmod;
	memset(&newmod,0,sizeof(newmod));
	newmod.modid=atoi(id);
	sprintf(newmod.modname,"%s",modname);
	sprintf(newmod.property,"%s",property);
	int ret=insert_mydb(mydb,tbname,newmod);//改函数
	if(ret<0)
	{
		printf("insert error ");
		
		send(newfd,"error",sizeof(5),0);
		return -1;
	
	}
	char zhucebuf[50]={'\0'};
	sprintf(zhucebuf,"newmod%s插入成功!",newmod.modname);
	printf("%s",zhucebuf);
	send(newfd,zhucebuf,sizeof(zhucebuf),0);
	return 0;


}
